<%@page import="com.mysql.jdbc.StringUtils"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.zhuozhengsoft.ZSOfficeX.*, java.awt.*, com.hnjowe.util.*, com.union.core.doc.model.*"%>
<%@ page import="com.union.core.doc.service.*"%>
<jsp:useBean id="ZSOfficeCtrl" scope="page" class="com.zhuozhengsoft.ZSOfficeX.ZSOfficeCtrl"></jsp:useBean>
<%request.setCharacterEncoding("UTF-8");%>
<%
java.util.List<SealSignature> sealSignatureList = ComUtil.getOfficialDocService().querySeal(new SealSignature(), 0, 0);

String docid = request.getParameter("docid");
String template_id = request.getParameter("template_id");
OfficialDoc officialDoc = ComUtil.getOfficialDocService().query(Long.parseLong(docid));
DocTemplate docTemplate = ComUtil.getOfficialDocService().queryTemplate(Long.parseLong(template_id));

String realOpenFileName = docTemplate.getFile_path();
if(!StringUtils.isNullOrEmpty(officialDoc.getDoc_file_path())){
	realOpenFileName = officialDoc.getDoc_file_path();
}
String showTitle = docTemplate.getTitle();
if(!StringUtils.isNullOrEmpty(officialDoc.getTitle())){
	showTitle = officialDoc.getTitle();
}

// 设置ZSOFFICE服务页面
ZSOfficeCtrl.ServerURL = "/zsserver.do";

// 设置界面样式
ZSOfficeCtrl.MainStyle = 2;
ZSOfficeCtrl.Caption = showTitle;
ZSOfficeCtrl.BorderStyle = 0;

//设置保存文档的服务器页面
ZSOfficeCtrl.SaveDocURL = "/doc/savedoc.jsp?docid=" + docid + "&template_id=" + template_id;

WordResponse wr = new WordResponse();
wr.DisableWindowRightClick = true;
ZSOfficeCtrl.assign(wr);
// 打开文档
ZSOfficeCtrl.webOpen(realOpenFileName, 2, "somebody", "Word.Document");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="/style/style.css" />
<script type="text/javascript" src="/js/jquery/lib/jquery-1.4.4.min.js"></script>
</head>
<body>
<div id="tishi" style="align:center"><h3><font color='red'>编辑后请点击左上角保存按钮或Ctrl+S保存文件，否则修改将不生效</font></h3></div>
<div id=formtop style="margin:5px;">
	<center>
		<span class=STYLE109>印章签名：</span>
		<SELECT name="officialDocPojo.seal_id" id="seal_id">
			<OPTION value="">请选择印章签名</OPTION>
			<%if(sealSignatureList != null && sealSignatureList.size() > 0){
				for(SealSignature ss : sealSignatureList){
			%>
				<OPTION value="<%=ss.getId() %>" sealpath="<%=ss.getFile_path()%>"><%=ss.getTitle() %></OPTION>
			<%}} %>
		</SELECT>
		<input type="button" onclick="insertSeal()" value="插入印章" />
	</center>
</div>
<!--************** ZSOffice客户端代码开始 ************************-->
<SCRIPT language="JavaScript" event="OnInit()" for="ZSOfficeCtrl">
    // 控件打开文档前触发，用来初始化界面样式
</SCRIPT>
<SCRIPT language="JavaScript" event="OnDocumentOpened(str, obj)" for="ZSOfficeCtrl">
    // 控件打开文档后立即触发，添加自定义菜单，自定义工具栏，禁止打印，禁止另存，禁止保存等等
    ZSOfficeCtrl.EnableFileCommand(0) = false;//禁止新建
    ZSOfficeCtrl.EnableFileCommand(1) = false;//禁止打开
    ZSOfficeCtrl.EnableFileCommand(4) = false;//禁止另存为
</SCRIPT>
<SCRIPT language="JavaScript" event="OnDocumentClosed()" for="ZSOfficeCtrl">
</SCRIPT>
<SCRIPT language="JavaScript" event="OnUserMenuClick(index, caption)" for="ZSOfficeCtrl">
    // 添加您的自定义菜单项事件响应
</SCRIPT>
<SCRIPT language="JavaScript" event="OnCustomToolBarClick(index, caption)" for="ZSOfficeCtrl">
    // 添加您的自定义工具栏按钮事件响应
</SCRIPT> 
<!-- 客户端控件引用 -->
<%=ZSOfficeCtrl.getDocumentView("ZSOfficeCtrl", request)%> 
<!--************** ZSOffice客户端代码结束 ************************--> 

<script type="text/javascript">
<!--
function insertSeal(){
	if($("#seal_id").val()==""){
		alert("请选择公章！");
		return;
	}
	ZSOfficeCtrl.InsertInlineWebImage($("#seal_id").find("option:selected").attr("sealpath"));
}
//-->
</script>
</body>
</html>